package cn.edu.nchu.controller;

import cn.edu.nchu.entity.CommonResult;
import cn.edu.nchu.entity.DeviceModel;
import cn.edu.nchu.service.DeviceMessageService;
import cn.edu.nchu.service.DeviceModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DeviceController {
    @Autowired
    private DeviceModelService deviceModelService;
    @Autowired
    private DeviceMessageService deviceMessageService;

    @GetMapping("/device_model/search/{deviceId}")
    public CommonResult<DeviceModel> search(@PathVariable("deviceId") String deviceId) {
        DeviceModel result = deviceModelService.findByDeviceId(deviceId);
        if (result != null) {
            return new CommonResult(200, "查询成功！", result);
        }
        return new CommonResult(300, "查询失败！", result);
    }
}
